<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/common/init.jsp"%>
<html>
<head>
<title>澳斯浪廷会员平台</title>
<link href="<c:url value='/resources/css/css.css'/>" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<c:url value='/resources/js/jquery-1.7.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/validate.js'/>"></script>
</head>
<body leftmargin="0">
<div class="main">
<div class="width_l">
    <iframe src="menu.action" frameborder="0" width="250" height="100%" class="menu"></iframe>
</div>    
    <div class="right">
    <div class="width_r">
        <div class="menu_r">
            <ul>
                <li><a href="index.action">首页</a></li>
                <li><a href="information.action">消息</a></li>
                <li><a href="notice.action">公告中心</a></li>
                <li><a href="news.action">新闻中心</a></li>
                <li><a href="inbox.action">收件箱</a></li>
                <li><a href="tomail.action">写邮件</a></li>
                <li><a href="sent.action">已发送</a></li>
                <li><a href="${ctx}/exit.action">安全退出</a></li> 
            </ul>
        </div>
        <div class="news_top"><img src="<c:url value='/resources/images/top.jpg'/>" /></div>
        <div class="news">
            <h4>修改密码</h4>
      <div class="mm"><form id="pwd" method="post">
                <div class="mm_left">会员 ID：<br />
原来三级密码：<br />
登录密码：<br />
登录确认：<br />
二级密码：<br />
二级密码确认：<br />
三级密码：<br />
三级密码确认：</div>
                <div class="mm_center">${user.userAccount}
<p><input name="thirdPassword" type="password" class="text" size="30" id="thirdPassword"/></p>
<p><input name="password11" type="password" class="text" size="30" id="password11"/></p>
<p><input name="password12" type="password" class="text" size="30" id="password12"/></p>
<p><input name="password21" type="password" class="text" size="30" id="password21"/></p>
<p><input name="password22" type="password" class="text" size="30" id="password22"/></p>
<p><input name="password31" type="password" class="text" size="30" id="password31"/></p>
<p><input name="password32" type="password" class="text" size="30" id="password32"/></p>
</div>
      <div class="mm_right">保持为空则为不修改<p>保持为空则为不修改</p><p>保持为空则为不修改</p></div>
            </form>
            </div>
            <div class="tijiao" onclick="doSave();"><img src="<c:url value='/resources/images/tijiao.jpg'/>" /></div>
        </div>
        <div class="news_down"><img src="<c:url value='/resources/images/down.jpg'/>" /></div>
    </div>
    </div>
</div>

</body>
</html>
<script type="text/javascript">
function doSave(){
	$.ajaxSetup({cache:false});
	var checkFlg = true;
	checkFlg = checkFlg && validateEmpty_jquery("原来三级密码", "thirdPassword");
	//checkFlg = checkFlg && false;
	$.ajax({
		type:'POST',
		url: "${ctx}/chkTidPwd.action",
		data: "thirdPassword="+$("#thirdPassword").val(),
		dataType:"html",
        async:false,  // 设置同步方式
        cache:false,
		success: function(data,status){
			if($.trim(data)!=''){
				setValidateErrorStyle_jquery($("#thirdPassword"));
				alert(data);
				checkFlg = checkFlg && false;
			}
		},
		error: function(data,status,e){
			alert(e.name);
		}
	});
	checkFlg = checkFlg && validateEmpty_jquery("登录密码", "password11");
	checkFlg = checkFlg && validateEmpty_jquery("确认登录密码", "password12");
	//alert($("#firstPwd").val()+"--"+$("#firstPwd2").val());
	if($("#password11").val() != $("#password12").val()){
		setValidateErrorStyle_jquery($("#password11"));
		setValidateErrorStyle_jquery($("#password12"));
		alert("两次输入的密码不相等");
	    checkFlg = false;
	}
	if($("#password21").val() != $("#password22").val()){
		setValidateErrorStyle_jquery($("#password21"));
		setValidateErrorStyle_jquery($("#password22"));
		alert("两次输入的密码不相等");
	    checkFlg = false;
	}
	if($("#password31").val() != $("#password32").val()){
		setValidateErrorStyle_jquery($("#password31"));
		setValidateErrorStyle_jquery($("#password32"));
		alert("两次输入的密码不相等");
	    checkFlg = false;
	}
	if ( !checkFlg ) return false;
    if (checkFlg) {
    	//var data = $("#othermember").formSerialize();
    	//document.forms[0].action = "${ctx}/savePassword.action";
        //document.forms[0].submit();
    	var data = $("#pwd").serialize();
		jQuery.ajax({
			url: "${ctx}/savePassword.action",
			type: "post",
			dataType:"html",
			data:data,
			async:false,
			success: function(jsondata){
				alert(jsondata);
				window.location.href = "${ctx}/password.action";
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
		    }
		});
    }
}
</script>